package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.GameOrder;

/**
 * 
 * @author 
 *
 */
@DAO
public interface GameOrderDAO{
	
	@SQL("select * from GameOrder where deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } #if(:t.code!=''){ and code like '%##(:t.code)%' } #if(:t.name!=''){ and name like '%##(:t.name)%' } #if(:t.school!=''){ and school like '%##(:t.school)%' } #if(:t.grade!=''){ and grade like '%##(:t.grade)%' } #if(:t.areaName!=''){ and areaName like '%##(:t.areaName)%' } #if(:t.schoolName!=''){ and schoolName like '%##(:t.schoolName)%' } #if(:t.parentName!=''){ and parentName like '%##(:t.parentName)%' } #if(:t.parentPhone!=''){ and parentPhone like '%##(:t.parentPhone)%' } #if(:t.status!=-1){ and status=:t.status } ORDER BY createAt DESC LIMIT :t.start,:t.length")
    List<GameOrder> query(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("SELECT count(*) FROM GameOrder WHERE deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } #if(:t.code!=''){ and code like '%##(:t.code)%' } #if(:t.name!=''){ and name like '%##(:t.name)%' } #if(:t.school!=''){ and school like '%##(:t.school)%' } #if(:t.grade!=''){ and grade like '%##(:t.grade)%' } #if(:t.areaName!=''){ and areaName like '%##(:t.areaName)%' } #if(:t.schoolName!=''){ and schoolName like '%##(:t.schoolName)%' } #if(:t.parentName!=''){ and parentName like '%##(:t.parentName)%' } #if(:t.parentPhone!=''){ and parentPhone like '%##(:t.parentPhone)%' } #if(:t.status!=-1){ and status=:t.status }")
    int querysize(@SQLParam("t") GameOrder gameOrder);
    
    @SQL("select * from GameOrder where id=:1")
    GameOrder queryById(int id);
    
    @SQL("INSERT INTO GameOrder (orderNo,userId,gameId,duration,permitId,areaName,schoolName,address,code,returnCode,price,parentName,parentPhone,name,identityCard,school,grade,status,payWay,source,deleteFlag,createAt,createUser,updateAt,updateUser,area,teacher) VALUES (:t.orderNo,:t.userId,:t.gameId,:t.duration,:t.permitId,:t.areaName,:t.schoolName,:t.address,:t.code,:t.returnCode,:t.price,:t.parentName,:t.parentPhone,:t.name,:t.identityCard,:t.school,:t.grade,:t.status,:t.payWay,:t.source,1,now(),:t.createUser,now(),:t.updateUser,:t.area,:t.teacher)")
    void create(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("UPDATE GameOrder SET parentName=:t.parentName,parentPhone=:t.parentPhone,name=:t.name,identityCard=:t.identityCard,school=:t.school,grade=:t.grade,updateAt=now(),updateUser=:t.updateUser,area=:t.area,teacher=:t.teacher WHERE id=:t.id")
    void update(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("UPDATE GameOrder SET status=:2,source=:3,payWay=:4,payOrder=:5,updateAt=now() WHERE id=:1")
    void updateStatusById(int id,int status,int source,int payWay,String payOrder);
    
    @SQL("UPDATE GameOrder SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("select status from GameOrder where identityCard=:1")
	List<Map> getIDCard(String identityCard);
    
    @SQL("select * from GameOrder where code=:1 and gameid=:2")
    List<Map> queryStatusByCode(String code,int gameid);
}